package operation;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-01-05
 * Time:2:08
 */
import book.Book;
import book.BookList;

public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书");
        System.out.println("请输入你要借阅的图书名字");
        String name = input.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);//得到所有图书的信息
            if(name.equals(book.getName())){//找到了
                book.setBorrowed(true);//把借阅状态给为true
                System.out.println("借阅成功");
                System.out.println(book);//打印这个图书信息
                return;
            }
        }
        System.out.println("没有你要借阅的这本书");
    }
}
